package com.wangyk.user.service.impl;

import com.wangyk.rabbitmqcommon.VO.ResultVO;
import com.wangyk.rabbitmqcommon.fdfs.FileFactory;
import com.wangyk.rabbitmqcommon.fdfs.IFileClient;
import com.wangyk.user.pojo.UploadFileReq;
import com.wangyk.user.service.UploadFileService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;

import java.io.IOException;

@Service
@Slf4j
public class UploadFileServiceImpl implements UploadFileService
{
    @Autowired
    private FileFactory fileFactory;

    @Override
    public ResultVO uploadFile(UploadFileReq uploadFileReq)
    {
        IFileClient creator = fileFactory.creator();
        MultipartFile file = uploadFileReq.getFile();

        try
        {
            String fileName = creator.uploadFile(file.getBytes(), "fileName");
            log.error(fileName);
        }
        catch (IOException e)
        {
            e.printStackTrace();
        }
        return null;
    }
}
